package com.codesuc.aichat.config;

import com.codesuc.aichat.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description 登录拦截器配置
 * @Author Mr.Zhang
 * @Date 2025/8/3 17:35
 * @Version 1.0
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 登录拦截器
        registry.addInterceptor(new LoginInterceptor())
                // 添加拦截的路径
                .addPathPatterns("/**")
                // 排除不拦截的路径
                .excludePathPatterns(
                        "/api/*/user/login",
                        "/api/*/user/register",
                        "/api/*/user/logout",
                        "/api/*/user/info",
                        "/api/*/role/**",
                        "/api/*/userFavorite/**",
                        "/api/*/aiAgent/**",
                        "/api/*/chatHistory/**"
                );

    }
}
